package com.fang.shiyan;



public class Consumer extends Thread {
    private Depository depository;
    private int products;
    private int maxProducts;




    public Consumer(Depository depository,int maxProducts) {
        this.depository = depository;

        this.maxProducts = maxProducts;
    }
    public void do_consume(){
        depository.consume();
    }

    @Override
    public void run() {
        while(products<maxProducts) {

            try {
                this.do_consume();

                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }

    public int getProducts() {
        return products;
    }

    public void setProducts(int products) {
        this.products = products;
    }
}
